import React from 'react';
import {Table} from 'acud';
import {RootObject} from '.';

interface Props {
    list: RootObject[];
    loading?: boolean;
}

const List: React.FC<Props> = ({list, loading}) => {

    list.forEach((item, index) => {
        item.key = index;
    });

    const columns = [
        {
            title: '名称',
            dataIndex: 'name',
        },
        {
            title: '价格',
            dataIndex: 'price',
            render: (text: string) => <>{text}￥</>,
        },
    ];

    return (
        <Table
            rowKey="key"
            loading={{loading, tip: '正在加载中...'}}
            pagination={false}
            dataSource={list}
            columns={columns}
        />
    );
};

export default List;
